#!/usr/bin/perl

my $numArgs = $#ARGV + 1;
if($numArgs < 3) { 
	print "Usage: $0 <input files folder> <flags for compiler> <output folder>\n";
	exit(0);
}

my $inputFolder = $ARGV[0];
my $compilerFlag = $ARGV[1];
my $outputFolder = $ARGV[2];

system "mkdir -p $outputFolder";

for my $file (<$inputFolder/*.ic>) {
	
	my $out = $file;
	
	$out =~ s/\.ic$/\.test/;
	$out =~ s/$inputFolder/$outputFolder/;
	
	system("../run '$file $compilerFlag' > $out 2>&1");
}

print "Created compiler output files in $outputFolder (from input files in $inputFolder)\n";



